
<%@ page import="java.sql.ResultSet" %>
<%@include file="/public.jsp"%><%--
  Created by IntelliJ IDEA.
  User: 698
  Date: 2025/6/24
  Time: 上午9:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="css/styless.css">
</head>
<body>
<form>
<%
    String readername =request.getParameter("readername");
    String idcard =request.getParameter("idcard");
    Statement stmt=conn.createStatement();
    String sql="SELECT * FROM readers t WHERE " +" 1=1 ";
    if(null!=readername && !"".equals(readername)){
        sql=sql+" AND  t.readername LIKE '%"+readername+"%' ";
    }
    if(null!=idcard && !"".equals(idcard)){
        sql=sql+" AND  t.idcard='"+idcard+"' ";
    }
    ResultSet rs=stmt.executeQuery(sql);
%>
<table align="center">
    <h1 align="center">欢迎进入读者信息</h1>
    <tr>
        <td>借阅人：<input type="text" name="readername" id="readername"></td>
        <td>身份证号码：<input type="text" name="idcard" id="idcard"></td>
    </tr>
    <tr>
        <td align="center" >
            <input type="hidden" name="actionType" value="reader">
            <input type="submit" value="查询">
            <input type="button" value="添加" onclick="reader_add()">

        </td>
    </tr>
</table>
<hr>
    <table align="center" width="80%" berder="1" >
    <tr>
        <td>读者ID</td>
        <td>借阅人</td>
        <td>性别</td>
        <td>身份证号</td>
        <td>学号</td>
        <td>联系方式</td>
        <td>操作</td>
    </tr>
    <tbody id="devList">
<%
        while(rs.next()) {
%>
    <tr>
        <td><%=rs.getString("readerid")%></td>
        <td><%=rs.getString("readername")%></td>
        <td><%=rs.getString("sex")%></td>
        <td><%=rs.getString("idcard")%></td>
        <td><%=rs.getString("xh")%></td>
        <td><%=rs.getString("phone")%></td>
        <td>
            <input type="button" value="修改" onclick="reader_update(<%=rs.getString("readerid")%>)">
            <input type="button" value="删除" onclick="reader_delete(<%=rs.getString("readerid")%>)">
        </td>
<%}%>

    </tr>
    </tbody>
</table>
</form>
<script type="text/javascript">
    function reader_add() {
        window.location.href="reader/reader_add.jsp";
    }
    function reader_update(readerid) {
        window.location.href="reader/reader_update.jsp?readerid="+ readerid;
    }
    function reader_delete(readerid) {
        window.location.href="reader/reader_delete.jsp?readerid="+ readerid;
    }
</script>
</from>
</body>
</html>
